#-*- coding: utf8 -*-
from tutor.scripts import *
from tutor.plugins.sympy import *

class Opts:
    class opt1:
        func = (x ** 2 - y ** 2 + x + y) / (x - y + 1)
        point = (0, 1)
        answer = 1

    class opt2:
        func = x * y / (x ** 2 + y ** 2)
        point = (0, 0)
        answer = None

    class opt3:
        numb = oneof(-1, 1) * oneof(1, 2, 3)
        func = (x ** 2 - y ** 2) / (abs(numb) * (x ** 3 - y ** 3))
        point = (numb, numb)
        answer = 3 * abs(numb)

    class opt4:
        numb = oneof(-1, 1) * oneof(1, 2)
        func = (x ** 3 - y ** 3) / (x ** 2 - y ** 2)
        point = (0, 0)
        answer = None

    class opt5:
        g = oneof(x * y, x + y, x ** 2 + y ** 2, sqrt(x * y))
        numb = oneof(1, 2, 3, 4, 5, 6)
        func = ((1 + g) ** numb - 1) / g
        point = (0, 0)
        answer = numb

# Entradas
opt = oneof(*[ o for o in dir(Opts) if o.startswith('opt') ])
opt = getattr(Opts, opt)
with display_block('Entradas'):
    func = opt.func
    point = opt.point
    answer = opt.answer
    vars = tuple(var(x) for (x, c) in zip('xyzw', point))

# Salva resposta
g0, g1, g2, g3, g4, g5, g6, g7 = [0] * 8
if answer is None:
    g7 = 1
else:
    locals()['g%s' % answer] = 1
    assert (answer in range(7))
    assert 1 in [ g0, g1, g2, g3, g4, g5, g6, g7 ]

# Mostra resultados
with display_block('Resultados'):
    answers = list(enumerate([ g0, g1, g2, g3, g4, g5, g6, g7 ]))

